import { setToken, getToken, delToken } from '@/utils/storage'

export default {
  namespaced: true,
  state: {
    token: getToken()
  },
  mutations: {
    // 更新 token
    updateToken (state, token) {
      state.token = token // 存到内存
      setToken(token) // 存到硬盘
    },
    // 退出登录
    logout (state) {
      state.token = null
      delToken()
    }
  }
}
